<template>
	<view class="cont_bo">
		<view class="icons_c">
			 <text class="cuIcon-roundcheckfill" style="color:#53A87F;font-size: 56rpx;"></text>
			 <view class="kp_ti" v-if="isComplete">{{ statusFlag == '1146' ? '开票中' : '已开票'}}</view>
			 <view class="kp_ti" v-else>开票中</view>
		</view>
		<view class="p_info">
			<view class="tits_mo">开票信息</view>
			<view>
			   <view class="mo_items">
			   	  <view class="it_n">公司抬头</view>
			   	  <view class="it_va">{{form.inv_name}}</view>
			   </view>
				 <view class="mo_items">
				 	  <view class="it_n">开票金额</view>
				 	  <view class="it_va">¥{{form.inv_money}}</view>
				 </view>
				 <view class="mo_items" v-if="isComplete">
				 	  <view class="it_n">开票方</view>
				 	  <view class="it_va">{{form.party}}</view>
				 </view>
				 <view class="mo_items">
				 	  <view class="it_n">开票时间</view>
				 	  <view class="it_va">{{form.creatsTimes}}
						</view>
				 </view>
				 <view v-if="isComplete">
						 <view class="mo_items">
						 	  <view class="it_n">发票内容</view>
						 	  <view class="it_va">商品费，配送费</view>
						 </view>
						<!-- <view class="mo_items">
						 	  <view class="it_n">发票号码</view>
						 	  <view class="it_va">{{form.need_invoice_id}}</view>
						 </view> -->
				 </view>
			</view>
		</view>
		<view class="p_info">
			<view class="tits_mo">接收方式</view>
			<view class="mo_items">
				  <view class="it_n">电子邮箱</view>
				  <view class="it_va">{{form.mail}}</view>
			</view>
		</view>
		<view class="full_btn fixed padding-top-lg text-lg">
			<view class="mbtn" @click="lookView">
				查看发票
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue';
	import { onShow ,onLoad} from '@dcloudio/uni-app';
	import { mnavTo } from '@/utils/helper';
	import {searchInfobyId } from '@/api/vmeitime-http/index.js'
	import mApi from "@/utils/mapi";
  const isComplete=ref(false)
	const needInvoice=ref('')
  const statusFlag = ref('')
	const form=ref<any>({})
	const loaded=ref(false)
	onLoad(options=>{
		if(options.invoicing=='1'){
			isComplete.value=false
		}else{
			isComplete.value=true
		}
		needInvoice.value=options.needInvoiceId
		loadData()
	})
	onShow(()=>{
		loaded.value&&loadData()
	})
	const loadData=async()=>{
		try{
			let res=await searchInfobyId({needInvoiceId:needInvoice.value})
			if(!res.result){
				return
			}
			loaded.value=true
			statusFlag.value = res.object.status
			form.value=res.object
			form.value.creatsTimes= `${res.object.create_date.slice(0, 4)}-${res.object.create_date.slice(4, 6)}-${res.object.create_date.slice(6, 8)}` + " " + res.object.create_date.slice(8, 10) + ":" + res.object.create_date.slice(10, 12) + ":" + res.object.create_date.slice(12, 14)
				
		}catch(e){
			loaded.value=true
		}

	}
	const lookView=()=>{
		if(!isComplete.value){
			mApi.msg("还在开票中!")
		}else{
			mnavTo('/pages/others/previewInv/previewInv?imgurl='+form.value.inv_image_url)
		}
	}
</script>

<style lang="scss" scoped>
	.cont_bo {
    width: 100vw;
		height: 100vh;
		background-color: #fff;
		padding: 60rpx 30rpx 10rpx 30rpx;
		.icons_c{
			display: flex;
			.kp_ti{
				color: #333;
				font-family: "Microsoft YaHei UI";
				font-size: 48rpx;
				font-weight: 400;
				margin-left: 15rpx;
			}
		}
		.p_info{
			width:100%;
			min-height: 100rpx;
			border-radius: 20rpx;
			box-shadow: 0px 0px 20px 0px rgba(86, 86, 86, 0.10);
			margin-top: 30rpx;
			padding: 40rpx;
			.tits_mo{
				color: #333;
				font-family: "Microsoft YaHei UI";
				font-size: 40rpx;
				font-weight: 700;
			}
			.mo_items{
				display: flex;
				margin-top: 29rpx;
				.it_n{
					color: #999;
					font-family: "Microsoft YaHei UI";
					font-size:32rpx;
					font-weight: 400;
					min-width: 120rpx;
				}
				.it_va{
					color: #333;
					font-family: "Microsoft YaHei UI";
					font-size:32rpx;
					font-weight: 400;
					letter-spacing: 0.32px;
					margin-left: 25rpx;
				}
			}
		}
		.accept{
			
		}
	}
</style>